import { useDispatch } from "react-redux"
import { findAllUser, addUserApi } from "../apis/userApi"
import { MyUserActionInit } from "../redux/actions/MyUserAction"
const useRequest = () => {
    const dispatch = useDispatch()
    //发送请求获取服务器数据
    const getUsers = async () => {
        const res = await findAllUser()
        if (res.data.code) {
            dispatch(MyUserActionInit(res.data.data))
        }
    }
    const addUser = (data) => {

    }
    //将数据存放状态机

    return { getUsers, addUser }
}


export default useRequest